package hks.saigyoujiyuyuko.bcverification.main;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

import hks.saigyoujiyuyuko.bcverification.Var.Var;
import net.md_5.bungee.api.connection.ProxiedPlayer;

public class Sthread implements Runnable {
	protected static ProxiedPlayer player;
	
	public Sthread(ProxiedPlayer player) {
		Sthread.player =player;
	}
	
	@Override
	public void run() {
		try {
			Var.socket =new Socket(Var.ServerIp, Var.ServerPort);
			Var.dInputStream =new DataInputStream(Var.socket.getInputStream());
			Var.dOutputStream =new DataOutputStream(Var.socket.getOutputStream());
			
			Var.dOutputStream.writeUTF("username:"+player.getName());
			Var.dOutputStream.writeUTF("token:"+Var.token);
			
			Var.socket.close();
			Var.dInputStream.close();
			Var.dOutputStream.close();
		} catch (UnknownHostException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}
	}

}
